package com.线程;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;

public class 线程结束 {

  static  volatile   int ai = 0 ;

    static AtomicInteger atomicInteger = new AtomicInteger(0);
    public static void main(String[] args) throws InterruptedException {

        CountDownLatch countDownLatch = new CountDownLatch(100*10000);

        ExecutorService service = Executors.newFixedThreadPool(1000);

        for(int i = 0 ; i < 100;i++){
            service.submit(new Runnable() {
                @Override
                public void run() {
                    for(int j =0 ; j <10000;j++){
                        atomicInteger.incrementAndGet();

                        countDownLatch.countDown();
                        ai++;
                    }

            //       System.out.println(countDownLatch.getCount());
                }
            });



        }

        countDownLatch.await();



        System.out.println(ai);


        System.out.println(atomicInteger.get());


        service.shutdown();



    }


}
